package com.songlanyun.modules.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.coupon.dao.CouponReceiveRecordUseDao;
import com.songlanyun.modules.coupon.entity.CouponReceiveRecordUseEntity;
import com.songlanyun.modules.coupon.service.CouponReceiveRecordUseService;


@Service("couponReceiveRecordUseService")
public class CouponReceiveRecordUseServiceImpl extends ServiceImpl<CouponReceiveRecordUseDao, CouponReceiveRecordUseEntity> implements CouponReceiveRecordUseService {

    @Override
    public CouponReceiveRecordUseEntity create(CouponReceiveRecordUseEntity entity) {
        return null;
    }

    @Override
    public CouponReceiveRecordUseEntity modify(CouponReceiveRecordUseEntity entity) {
        return null;
    }

    @Override
    public void remove(Long id) {

    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CouponReceiveRecordUseEntity> page = this.page(
                new Query<CouponReceiveRecordUseEntity>().getPage(params),
                new QueryWrapper<CouponReceiveRecordUseEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void recordOrder(Long recordId, Long orderId, String orderCode, BigDecimal couponResultValue) {
        CouponReceiveRecordUseEntity entity = new CouponReceiveRecordUseEntity();
        entity.setOrderId(orderId);
        entity.setCouponReceiveRecordId(recordId);
        entity.setOrderCode(orderCode);
        entity.setCouponResultValue(couponResultValue);
        this.baseMapper.insert(entity);
    }

    @Override
    public List<CouponReceiveRecordUseEntity> loadByRecordId(Long id) {
        return this.baseMapper.selectList(new LambdaQueryWrapper<CouponReceiveRecordUseEntity>()
        .eq(CouponReceiveRecordUseEntity::getCouponReceiveRecordId,id));
    }

}
